package com.fzz.controller;

import com.fzz.domain.User;
import com.fzz.service.UserService;
import com.fzz.serviceImpl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@Component
public class UserController {

    @Autowired
    private UserService userService=new UserServiceImpl();

    //注册用户
    @RequestMapping(value = "/toUserRegister/")
    public String toUserRegister()
    {
        return "user_register";
    }

    //注册
    @RequestMapping(value = "/user/register")
    public String userRegister(User user)
    {
        System.out.println(user);
        Integer rows = userService.userRegister(user);
        if(rows>0)
        {
            return "redirect:/login.html";
        }
        else
        {
            return "user_register";
        }
    }
}
